package done.easy_001_100;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * 13. Romain to Integer 罗马转数字
 * <p>
 * Symbol  Value
 * I       1
 * V       5
 * X       10
 * L       50
 * C       100
 * D       500
 * M       1000
 * <p>
 * 示例 4:
 * 输入: "LVIII"
 * 输出: 58
 * 解释: L = 50, V= 5, III = 3.
 * <p>
 * 示例 5:
 * 输入: "MCMXCIV"
 * 输出: 1994
 * 解释: M = 1000, CM = 900, XC = 90, IV = 4.
 *
 * @author 大硕
 * 2019-03-21 11:10 PM
 **/
@Slf4j
public class RomanToInteger {

    @SuppressWarnings("all")
    public int romanToInt(String st) {
        // 190408 first
        return -1;
    }

    @Test
    public void test() {
//        log.info("result:{}", romanToInt("IV"));
        assertEquals(romanToInt("MCMXCIV"), 1994);
    }
}





























/*
public int romanToInt(String st) {
    char[] s = st.toCharArray();
    int res = 0;
    Map<Character, Integer> m = new HashMap<Character, Integer>();
    m.put('I', 1);
    m.put('V', 5);
    m.put('X', 10);
    m.put('L', 50);
    m.put('C', 100);
    m.put('D', 500);
    m.put('M', 1000);
    for (int i = 0; i < s.length; ++i) {
        if (i == 0 || m.get(s[i]) <= m.get(s[i - 1]))
            res += m.get(s[i]);
        else
            res += m.get(s[i]) - 2 * m.get(s[i - 1]);
    }
    return res;
}
*/
